/*
 * @Author: kimsoso
 * @Date: 2022-01-06 14:00:27
 * @LastEditTime: 2022-02-28 17:13:15
 * @LastEditors: Please set LastEditors
 * @Description: 全局参数定义
 * @FilePath: /file-sync/ctypes/defines.go
 */
package defines

// 文件列表结构体
type Cfile struct {
	FileMd5         string `yaml:"fileMd5"`
	FileName        string `yaml:"fileName"`
	FileSize        int64  `yaml:"fileSize"`
	BlockSize       int64  `yaml:"blockSize"`
	FileMask        string `yaml:"fileMask"`
	CreateTime      string `yaml:"createTime"`
	CreateTimeStamp int64  `yaml:"createTimeStamp"`
	Expiration      int64  `yaml:"expiration"`
	Checked         bool   `yaml:"checked"`
}

const (
	DirFlagFile = ".ctrh"
)

const (
	FileDeleteExpireDuration = 3600  //数据删除后的缓冲时间（待其他节点删除）
	RetryTimes               = 3     //次
	SocketTimeout            = 10    //秒
	BufSize                  = 32768 //缓冲大小

)

const (
	COMM_TEST             = "COMM:TEST"             //测试命令
	COMM_CLOSE            = "COMM:CLOSE"            //退出
	COMM_NOTREADY         = "COMM:NOTREADY"         //没有准备好
	COMM_SWITCH           = "COMM:SWITCHHOST"       //切换Node
	COMM_REQNEWFILE       = "COMM:REQNEWFILE"       //请求新文件通知
	COMM_SendNewFile      = "COMM:SendNEWFILE"      //请求新文件通知
	COMM_ReadyReceiveFile = "COMM:ReadyReceiveFIle" //准备接收文件数据

	COMM_OK         = "COMM:SUCCESS"    //成功
	COMM_FAILED     = "COMM:FAILED"     //失败
	COMM_REVBLOCK   = "COMM:REVBLOCK"   //请求数据块
	COMM_BLOCKREQ   = "COMM:BLOCKREQ"   //请求传输块
	COMM_BLOCKEMPTY = "COMM:BLOCKEMPTY" //没有该文件的所有数据块
	COMM_BLOCKNOT   = "COMM:BLOCKNOT"   //没有该数据块
	COMM_BLOCKNEXT  = "COMM:BLOCKNEXT"  //下一个数据块
)

const (
	CLI_SENDFILE  = "CLI:NEWFILE"  //发送新文件
	CLI_SYNCFILE  = "CLI:SYNCFILE" //同步文件或目录
	CLI_DELFILE   = "CLI:DELFILE"  //删除文件
	CLI_DELFILES  = "CLI:DELFILES" //删除多个文件或文件夹
	CLI_FILE_LIST = "CLI:FILELIST" //罗列文件
	CLI_RNMFILE   = "CLI:RNMFILE"  //修改文件名
)

const (
	CLI_FILE_NOTEXIST  = iota - 1 //文件不存在
	CLI_FILE_NOTCHECK             //文件没有被校验
	CLI_FILE_DELETED              // 删除成功
	CLI_FILE_ALDELETED            //已经被删除
)
